import {usePost} from "@/utils/request";
import type {API} from "@/type/type";

/**
 * 获取文件下载地址
 * @param fileId
 */
export function toFileUrl(fileId: string | number) {
  return `/api/file/download/${fileId}`
}

/**
 * 文件上传
 */
export const uploadFileAPI = (file: File) => {
  const formData = new FormData()
  formData.append('file', file)
  return usePost<API.IFile>('/file/upload', formData)
}
